package Atm01;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseListener;

/**
 * 菜单界面
 */

public class MenuPanel extends JPanel implements ActionListener {
    private ATMFrame atmFrame;
    private ImageIcon saveImg = new ImageIcon("Images/buttonSave.jpg");
  //取款
    private ImageIcon getSaveImg= new ImageIcon("Images/buttonGet.jpg");
 //查询
    private ImageIcon findImg= new ImageIcon("Images/buttonFind.jpg");
//改密
   private ImageIcon modifyImg= new ImageIcon("Images/buttonModify.jpg");
//退出
    private ImageIcon offImg= new ImageIcon("Images/buttonOff.jpg");
 //转账
 private ImageIcon transferPanelImg= new ImageIcon("Images/TransferPanel.jpg");

//    private ChangePwdPanel changePwdPanel=new ChangePwdPanel();

    private JButton saveBtn = new JButton(saveImg);
    private JButton getSaveBtn=new JButton(getSaveImg);
    private JButton findBth=new JButton(findImg);
    private JButton modifyBth=new JButton(modifyImg);
    private JButton offBth=new JButton(offImg);
    private JButton transferPanelBth =new JButton(transferPanelImg);

    public MenuPanel(ATMFrame atmFrame){
     this.atmFrame=atmFrame;
        this.setLayout(null);
        saveBtn.setBounds(0,150,140,50);

        getSaveBtn.setBounds(0,250,140,50);

        findBth.setBounds(0,350,140,50);

        modifyBth.setBounds(884,150,140,50);

        offBth.setBounds(884,350,140,50);


        transferPanelBth.setBounds(884,250,140,50);


        this.add(findBth);
        this.add(saveBtn);
        this.add(getSaveBtn);
        this.add(modifyBth);
        this.add(offBth);
        this.add(transferPanelBth);

        saveBtn.addActionListener(this);
         getSaveBtn.addActionListener(this);
        findBth.addActionListener(this);
        modifyBth.addActionListener(this);
        offBth.addActionListener(this);
        transferPanelBth.addActionListener(this);




        this.setOpaque(false);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
          if(e.getSource()==saveBtn){
              atmFrame.switchPanel("save");
          }else if(e.getSource()==getSaveBtn){
              atmFrame.switchPanel("get");
          }else if(e.getSource()==findBth){
             atmFrame.getSearchPanel().showBlance();
//             atmFrame.init();

              atmFrame.switchPanel("searchPanel");
          }else if(e.getSource()==modifyBth){

              atmFrame.switchPanel("changPwd");
          }else if(e.getSource()==transferPanelBth){
              atmFrame.switchPanel("transferPanel");
          }else if(e.getSource()==offBth){
              atmFrame.switchPanel("login");
          }
    }
}
